package top.lingkang.securityoauth2.server.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import top.lingkang.securityoauth2.core.utils.PrivateAccessUtils;
import top.lingkang.securityoauth2.server.common.CommonServer;

import javax.annotation.PostConstruct;

/**
 * @author lingkang
 * Created by 2022/7/1
 * 首先加载的配置类，对oauth2进行全局配置
 */
@Configuration
public class Oauth2ServerConfiguration {
    protected final Logger logger = LoggerFactory.getLogger(Oauth2ServerConfiguration.class);
    private Oauth2ServerProperties serverProperties = new Oauth2ServerProperties();
    @Autowired
    private SecurityOauth2Server securityOauth2Server;

    @PostConstruct
    private void init() throws Exception {
        configuration(serverProperties);
        logger.info("授权服务端初始化完成...");
        PrivateAccessUtils.resetPrivateValue(securityOauth2Server, "serverProperties", serverProperties);
        CommonServer.serverProperties=serverProperties;
    }

    protected void configuration(Oauth2ServerProperties serverProperties) {

    }

}
